<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of addquestion
 *
 * @author Miss
 */
include_once("adb.php");
class healthclass extends adb{
    function healthclass(){
			adb::adb();
		}
		
		/**
		*query all applicant in the table and store the dataset in $this->result	
		*@return if successful true else false
		*/
		
		function get_all_health()
                {
			$query="Select * from health_promotion";
                       // print $query;
			return $this->query($query);
		}
			
		function add_promotion($date,$venue,$topic,$method,$audience,$numaudience,$remarks,$month,$latitude,$longitude,$image,$idcho,$subdid)
                {
			$query ="Insert into health_promotion (date, venue, topic,method,target_audience,number_of_audience,remarks,month,latitude,longitude,image,idcho,subdistrict_id)values ('$date','$venue','$topic','$method','$audience','$numaudience','$remarks','$month','$latitude','$longitude','$image',$idcho,$subdid)";
			return $this->query($query);
		}
                
                function get_health_by_id($id)
                {
                    $query="Select * from health_promotion where idhealth_promotion =$id";
                       //print $query;
			return $this->query($query);
                }
                
                
                        function search_health($toSearch)
                {
                    $query ="Select * from health_promotion where topic like '%$toSearch%' or venue like '%$toSearch%'";
                   // print $query;
                    return $this->query($query);
                }
                
                function update_health($id, $date,$venue,$topic,$method,$audience,$numaudience,$remarks,$month,$latitude,$longitude,$image,$subdid)
                {
                   $query = "update health_promotion set date= '$date', venue ='$venue',
                            topic = '$topic',method = '$method',target_audience = '$audience',
                           number_of_audience = $numaudience,remarks = '$remarks',month = '$month',
                           latitude = $latitude,longitude = $longitude,image = '$image',subdistrict_id = $subdid where idhealth_promotion = $id";
                   //print $query;
                   return $this->query($query);
                }
                
                function delete($id)
                {
                     $query = "Delete from health_promotion where idhealth_promotion =$id";
                        //print $query;
                        return $this->query($query); 
                }
		
		/**
		*updates the record identified by id 
		*/
//		function update_applicant($applicant_id,$firstname,$lastname,$othernames,$address,$residence,$relationahip_to_child,$workplace,$consent_id){
//			//write the SQL query and call $this->query()
//			$query="update applicant set firstname='$firstname',lastname='$lastname',othernames='$othernames',
//			address='$address',residence='$residence',relationahip_to_child='$relationahip_to_child',workplace='$workplace',consent_id='$consent_id',
//			last_modified=now()	where applicant_id=$applicant_id";
//			return $this->query($query);
//		}
//		/**
//		*query to delete a applicant 	
//		*@return if successful true else false
//		*/
//		function delete_applicant($applicant_id){
//			$query="Delete from applicant where applicant_id=$applicant_id";
//			return $this->query($query);
//		}
//		
//		function get_applicant_byID($applicant_id){
//			$query="Select * from applicant where applicant_id=$applicant_id";
//			return $this->query($query);
//		}
		
   
                //put your code here
               
                
                
}

 //$obj = new category();
 
// if($obj->get_all_categories())
// {
//     echo"cannot find categories";
// }//
// 
//  echo"fetching";
//     $row = $obj->fetch();
//     while ($row)
//     {
//         echo $row['name'];
//         $row = $obj->fetch();
//     }
  
// else
// {
//      
// }
// echo"fetching";
// 
 ?>